Closed
Conversation
Relevant lines pasted from the grammar:
```c
//G is-as-expression:
//G prefix-expression
//G is-as-expression is-value-constraint
//GTODO type-id is-type-constraint
```
A *prefix-expression* can be an *unqualified-id*, which can also be a
*type-id*. So when the latter is implemented, it would break any code
using `identifier is` to test an expression.
I understand the usual way of disambiguating is to require parens, so I
have done that here to fix 5 `regression_tests`.
JohelEGP
suggested changes
Oct 25, 2023
| auto is() -> std::false_type { return {}; } | ||
|
|
||
| template <typename X, typename C> | ||
| requires std::same_as<X, C> || std::derived_from<X,C> |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Contributor
There was a problem hiding this comment.
Sorry, I was wrong.
std::same_as can be true for non-class types,
whereas std::derived_from can only be true for classes.
Co-authored-by: Johel Ernesto Guerrero Peña <johelegp@gmail.com> Signed-off-by: Nick Treleaven <ntrel002@gmail.com>
Contributor
|
What about the alternative grammar? |
Contributor
If this implements #358 (comment), |
Owner
|
Hi! Sorry it took me so long to get to this one. I'm going to close it as probably-dated now, but if you want to pursue it please reopen and refresh. Thanks again, and sorry again for the lag. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This supplants #759. The same rationale applies for requiring
(identifier) isto test an expression, see that PR for details. I added a diagnostic foridentifier is exprwhereexpris not a type-id, becauseType is expris not valid - instead it will suggest using(identifier) is.cpp2util.hchanges are taken from #701 by @filipsajdak. That makesstd::runtime_error is std::exceptiontrue, which seems correct, although I think that is not mentioned in P2392.I had to add a
speculativeparameter toparser::type_id()which istruewhen there might not be a type (but an expression instead). This avoids an error forptr*which is parsed as a postfix-expression from prefix-expression from is-as-expression.